<!DOCTYPE html>
<!--
 *  创建时间: 2020-08-05-8:53
 *  作   者: lpc
 *  Email : lpc@hll520.cn
-->
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <meta name="description" content="">
    <meta name="author" content="">
    <title>订单详情</title>
    <!-- JQuery -->
    <script type="text/javascript" src="/static/js/jquery.min.js"></script>
    <!-- Bootstrap核心CSS和JS -->
    <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <!-- 自定义JS -->
    <script type="text/javascript">
        $(function () {

            /* 获取用户信息 */
            $.getJSON(
                "/user/getInfo",
                {},
                function (json) {
                    if (json.statusCode !== 200) {

                    } else {
                        $("#nav_login").html(`
                        <a href="/space">
                        <span class="glyphicon glyphicon-user"></span>
                        <span id="userName">${json.data.realname}</span></a>
                        `);

                        $("#nav_register").html(`
                    <a href="/user/signOut">安全退出</a>
                    `);

                    }
                },
                "json"
            );

            $.getJSON(
                location.href + "/getInfo",
                {},
                function (json) {
                    if (json.statusCode !== 200) {
                        alert("没找到订单！"+json.msg);
                        location.href="/home"
                        return false;
                    }
                    let orderList = json.data;
                    for (let i = 0; i < orderList.length; i++) {

                        let order = orderList[i];
                        let price = order.goodsPrice * order.goodsCount/100;
                        /* 赋值 */
                        priceAll += price;
                        orderTime = order.createDate;
                        orderKey = order.orderKey;
                        orderStatus=order.orderStatus;
                        /* 显示清单 */
                        $("#order_info").append(`
                        <tr>
                        <td>暂无图片</td>
                        <td>${order.goodsName}</td>
                        <td>${order.goodsPrice}</td>
                        <td>${order.goodsCount}</td>
                        <td>${price}</td>
                        <td>${order.createDate}</td>
                        <td><a href="#">移除</a></td>
                        </tr>
                        `);
                    }
                    /* 设置总价格时间和订单编号 */
                    $("#price_all").html(priceAll);
                    $("#order_id").html(orderKey);
                    $("#time").html(orderTime);
                    $("#status").html(orderStatus);
                }
            );


            /* 支付 */
            $("#btn_pay").click(function () {
                $.getJSON(
                    "/order/"+orderKey+"/pay",
                    {payPrice:99999},
                    function (json) {
                        if(json.statusCode!==200){
                            alert(json.msg);
                            return false;
                        }
                        alert("支付成功");
                        location.href="/order/list";
                    }
                )
            });


        });

        var orderKey = "";
        var priceAll = 0;
        var orderTime;


        /* 搜索 */
        function search() {
            let key = $("#key").val();
            location.href = "/goods/search/" + key;
        }
    </script>
</head>
<body>
<div class="container">

    <!-- 导航 -->
    <nav class="navbar navbar-default" role="navigation">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse"
                    data-target="#bs-example-navbar-collapse-1"><span
                    class="sr-only">WTUShop导航栏</span><span class="icon-bar"></span><span
                    class="icon-bar"></span><span class="icon-bar"></span></button>
            <a class="navbar-brand" href="/">WTUShop</a>
        </div>

        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <!-- 左边 -->
            <ul class="nav navbar-nav">
                <li ><a href="/goods/search">商场</a></li>
                <li><a href="/kill/list">秒杀活动</a></li>
                <li><a href="/space/">个人中心</a></li>
                <li><a href="/admin/manage">控制台</a></li>
            </ul>
            <!-- 右边 -->
            <ul class="nav navbar-nav navbar-right">
                <li><a href="/shopping/list">购物车</a></li>
                <li class="active"><a href="/order/list">订单查询</a></li>
                <li id="nav_login"><a href="/login"><span
                        class="glyphicon glyphicon-user"></span><span id="userName">请登录</span></a></li>
                <li id="nav_register"><a href="/register">注册</a></li>
                <li>&nbsp;&nbsp;</li><!-- 占位符 -->
            </ul>
        </div>

    </nav>
    <!-- 标题和搜索 -->
    <div class="row clearfix page-header">
        <div class="col-md-8 column" >
            <a href="/"><h1>WTUShop</h1></a>
        </div>

        <div class="input-group col-md-4 column " style="margin-top: 20px">
            <input type="text" class="form-control" placeholder="搜索商品" id="key">
            <span class="input-group-btn">
                <a href="javaScript:search()">
                <button id="btn_search" class="btn btn-default">
                    <span class="glyphicon glyphicon-search"></span> 搜索
                </button>
                    </a>
                    &nbsp;
            </span>
        </div>
    </div>


    <div class="row clearfix">


        <div class="col-md-12 column">
            <ul class="breadcrumb">
                <li><a href="/order/list">订单</a></li>
                <li><a href="/order/info">订单详情</a></li>
                <li class="active">支付</li>
            </ul>


            <div class="row clearfix">
                <div class="col-md-6 column">
                    <h3>
                        订单编号：<span style="color: cornflowerblue;" id="order_id">100088</span>
                    </h3>
                </div>
                <div class="col-md-6 column text-right">
                    <h3>
                        订单状态：<span style="color: firebrick;" id="status">未支付</span>
                    </h3>
                </div>
            </div>


            <table class="table table-hover table-bordered table-striped">
                <thead>
                <tr>
                    <th>预览</th>
                    <th>商品</th>
                    <th>单价</th>
                    <th>数量</th>
                    <th>小计</th>
                    <th>添加时间</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody id="order_info">


                </tbody>
            </table>


            <div class="row clearfix">
                <div class="col-md-4 column">
                    <span>下单时间：</span>
                    <span><b id="time">2020-02-02 02:02:02</b></span>
                </div>

                <div class="col-md-4 column text-right">
                    <span>总价：</span>
                    <span style="color: red;font-size: 28px" id="price_all">29999</span>
                </div>

                <div class="col-md-4 column text-bottom">
                    <button type="button" class="btn btn-default btn-block btn-primary" id="btn_pay">
                        支付
                    </button>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
</html>